#include "HolePoint.h"
#include "BaseTooth.h"
#include "BaseBadPoint.h"

HolePoint::HolePoint(void)
{
	kind = HOLE;
}

HolePoint::~HolePoint(void)
{
	badPoint->autorelease();
}

HolePoint::HolePoint(BaseTooth::Position toothKind){
	op = 255;
	scheFlag = true;
	switch(toothKind){
		case BaseTooth::UP_LEFT_ONE:	
			badPoint = CCSprite::create("dentist/img_sr_1280_720_damage_hole_t30006_png.png");
			badPoint->setPosition(ccp(208,149));
			badPoint->setZOrder(2); 
			addChild(badPoint);	
			;break; 
		case BaseTooth::UP_LEFT_TWO:	;break; 
		case BaseTooth::UP_LEFT_THREE:
			badPoint = CCSprite::create("dentist/img_sr_1280_720_damage_hole_t10006_png.png");
			badPoint->setPosition(ccp(236,149));
			badPoint->setZOrder(2);   
			addChild(badPoint);		
			break; 
		case BaseTooth::UP_LEFT_FOUR:	;break; 
		case BaseTooth::UP_LEFT_FIVE:	;break; 
		case BaseTooth::UP_LEFT_SIX:	;break; 
		case BaseTooth::DOWN_LEFT_ONE:	;break; 
		case BaseTooth::DOWN_LEFT_TWO:	;break; 
		case BaseTooth::DOWN_LEFT_THREE:	;break; 
		case BaseTooth::DOWN_LEFT_FOUR:	;break; 
		case BaseTooth::DOWN_LEFT_FIVE:	;break; 
		case BaseTooth::DOWN_LEFT_SIX:	;break; 
	}
}

bool HolePoint::fixBadTooth(){
	if(scheFlag){
		schedule(schedule_selector(HolePoint::remove), 0.5f);
		scheFlag = false;
	}
	return true;
}

void HolePoint::remove(float dt)
{
		if(badPoint->getOpacity() != 0){
			badPoint->setOpacity(op);
			op-=51;
		}
       CCLOG("scheduler removed %i", op);
}

void HolePoint::stopFix(){	
	unschedule(schedule_selector(HolePoint::remove));
	scheFlag =true;
	CCLOG("scheduler removed");
}